<template>
	<view id="app">
		<bilihaerder :objData="haderObj" @acctevt="acctevt" @click="clickFind" @stair="stairClassify" ref="ification">
		</bilihaerder>
		<!-- <view v-for="item in dataimgArrl">
			<image v-for="url in item.listimgs" :src="'http://192.168.1.107:8978/'+item.path +url" mode=""></image>
		</view>
 -->
		<!-- <view class="wrap">
			<u-swiper :list="list" :effect3d="true"></u-swiper>
		</view> -->
		<bililistLine :listData="listData" :isTypeClass="isTypeClass" @mores="mores" @theCurrent="theCurrent">
		</bililistLine>

		<!-- <bililistLine v-for='item in listData' :pic='item.pic' :title='item.title' :plays='item.stat.view' :barrage='item.stat.danmaku'></bililistLine> -->
		<!-- <biliSymmetry></biliSymmetry> -->
		<!-- <biliSlide>
			<template name="sliks">
					<view class="">
						123123
					</view>
				</template>
		</biliSlide> -->
		<!-- <view class="contentBox">
				<view class="box" v-for="item in 5">
					<view>
						<img src='../../../../static/logo.png'>
					</view>
					<view>
						<text class="msgtxt">是德国哈山东黄金阿斯蒂芬干哈速度发货就卡死的风格</text>
						<view>
<u-tag text="狼狈为奸" mode="plain" />
</view>
						<text class="txt">爱得疯狂加班的v阿散井康拉德VS</text>
						<text class="txt"> 爱得疯狂加班的v阿散井康拉德VS</text>
					</view>
				</view>
			</view> -->
		<loading v-if="listData.length === 0"></loading>
	</view>
</template>

<script>
	import {
		regionTags
	} from "../../../../../utlis/bilibili.js";
	export default {
		data() {
			return {
				list: [],
				dataimgArrl: [],
				haderObj: {},
				listData: [],
				pageObj: {
					page: 1,
				},
				keyid: "",
				isTypeClass: false
			};
		},
		onLoad() {
			this.theSearch();
			this.getlistConditio();
		},

		onPullDownRefresh() {
			this.pageObj.page = 1;
			this.getlistConditio();
		},
		onReachBottom() {
			const {
				count,
				num,
				size
			} = this.pageObj;
			this.pageObj.page++;
			if (count !== num) {
				this.getlistConditio(this.keyid);
			}
		},
		methods: {
			async stairClassify({
				key: day,
				name,
				blocks
			}) {
				this.listData = [];
				this.isTypeClass = true;
				let rid = [];
				blocks.forEach(i => {
					rid.push(i.key)
				})
				let data = await this.http(this.api.typeRecommend, {
					rid,
					day
				})
				for (let k in data) {
					//#ifdef H5
					if (Array.isArray(data[k]['data'])) {
						data[k]['data'].forEach(async (item) => {
							item.pic =
								this.baseHttpUrl +
								await this.http(
									this.api.bilibili_get_img, {
										url: item.pic
									},
									"GET"
								)
						})
					}
					//#endif
					this.listData.push(data[k])
				}
				regionTags.data = this.listData

			},
			async getimg() {
				this.dataimgArrl = await this.http(this.api.silkAll);
			},
			async theSearch() {
				let data = await this.http(this.api.bl_Collectionl);
				this.haderObj = {
					data,
					regionTags,
				};
			},
			acctevt({
				key,
				name,
				classify
			}) {
				this.isTypeClass = false;
				this.keyid = key;
				this.getlistConditio(key);
				this.listData = [];
				regionTags
				console.log('*************------',key,
					name,
					classify);
					
			},
			async getlistConditio(rid) {
				let data = await this.http(this.api.bl_region, {
					pn: this.pageObj.page,
					ps: 20,
					rid: rid || 1,
				});
				this.pageObj = Object.assign(this.pageObj, data.page);
				//#ifdef H5
				data.archives.forEach(async (item) => {
					item.pic =
						this.baseHttpUrl +
						await this.http(
							this.api.bilibili_get_img, {
								url: item.pic
							},
							"GET"
						)
				});
				//#endif
				uni.stopPullDownRefresh();
				this.listData = [...this.listData, ...data.archives];
			},
			clickFind(val) {
				uni.navigateTo({
					url: `./teSearch?data=${JSON.stringify(this.haderObj.data)}`,
				});
			},
			theCurrent(data) {
				uni.navigateTo({
					url: `./info?data=${JSON.stringify(data)}`,
				});
			},
			mores({
				day,
				rid,
				type
			}) {
				console.log(rid);
				let arrnew = regionTags[1].blocks.map((item, index) => {
					return item.key
				})
				let index = arrnew.findIndex((value, index, arr) => {
					return value == rid
				})
				this.$refs.ification.secondLevelpitch = parseInt(rid)

				console.log(this.$refs.ification);
			},
		},
	};
</script>

<style scoped lang="less">
	.wrap {
		padding: 10rpx;
	}
</style>
